using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Web.UI.HtmlControls;

namespace MessageBoardControl
{
	/// <summary>
	/// Summary description for ManageSecurity.
	/// </summary>
	[DefaultProperty("Text"), 
	ToolboxData("<{0}:ManageSecurity runat=server></{0}:ManageSecurity>")]
	public class ManageSecurity : System.Web.UI.WebControls.WebControl, INamingContainer, IPostBackDataHandler
	{
		protected DropDownList cmbUsers = new DropDownList();
		protected Button cmdAdd = new Button();
		protected Button cmdOk = new Button();
		protected Button cmdCancel = new Button();
		protected string id;

		#region Properties

		private string urlAfter;
		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public string URLAfter 
		{
			get
			{
				return urlAfter;
			}

			set
			{
				urlAfter = value;
			}
		}

		private string text;
	
		[Bindable(true), 
			Category("Appearance"), 
			DefaultValue("")] 
		public string Text 
		{
			get
			{
				return text;
			}

			set
			{
				text = value;
			}
		}

		private MessageBoard.Group group;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Group Group 
		{
			get
			{
				return group;
			}

			set
			{
				group = value;
			}
		}

		private MessageBoard.Category category;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Category Category 
		{
			get
			{
				return category;
			}

			set
			{
				category = value;
			}
		}

		private MessageBoard.Forum forum;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Forum Forum 
		{
			get
			{
				return forum;
			}

			set
			{
				forum = value;
			}
		}

		private MessageBoard.Thread thread;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Thread Thread 
		{
			get
			{
				return thread;
			}

			set
			{
				thread = value;
			}
		}

		private MessageBoard.Post post;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Post Post 
		{
			get
			{
				return post;
			}

			set
			{
				post = value;
			}
		}

		private MessageBoard.Language language;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")] 
		public MessageBoard.Language Language 
		{
			get
			{
				return language;
			}

			set
			{
				language = value;
			}
		}
		#endregion

		#region Radio
		protected RadioButton rdoCanViewGroups0					= new RadioButton(),	rdoCanViewGroups1					= new RadioButton(),	rdoCanViewGroups2					= new RadioButton();
		protected RadioButton rdoCanViewCategories0				= new RadioButton(),	rdoCanViewCategories1				= new RadioButton(),	rdoCanViewCategories2				= new RadioButton();
		protected RadioButton rdoCanViewForums0					= new RadioButton(),	rdoCanViewForums1					= new RadioButton(),	rdoCanViewForums2					= new RadioButton();
		protected RadioButton rdoCanViewThreads0				= new RadioButton(),	rdoCanViewThreads1					= new RadioButton(),	rdoCanViewThreads2					= new RadioButton();
		protected RadioButton rdoCanViewPosts0					= new RadioButton(),	rdoCanViewPosts1					= new RadioButton(),	rdoCanViewPosts2					= new RadioButton();
		protected RadioButton rdoCanAddGroups0					= new RadioButton(),	rdoCanAddGroups1					= new RadioButton(),	rdoCanAddGroups2					= new RadioButton();
		protected RadioButton rdoCanAddCategories0				= new RadioButton(),	rdoCanAddCategories1				= new RadioButton(),	rdoCanAddCategories2				= new RadioButton();
		protected RadioButton rdoCanAddForums0					= new RadioButton(),	rdoCanAddForums1					= new RadioButton(),	rdoCanAddForums2					= new RadioButton();
		protected RadioButton rdoCanAddThreads0					= new RadioButton(),	rdoCanAddThreads1					= new RadioButton(),	rdoCanAddThreads2					= new RadioButton();
		protected RadioButton rdoCanAddPosts0					= new RadioButton(),	rdoCanAddPosts1						= new RadioButton(),	rdoCanAddPosts2						= new RadioButton();
		protected RadioButton rdoCanEditGroups0					= new RadioButton(),	rdoCanEditGroups1					= new RadioButton(),	rdoCanEditGroups2					= new RadioButton();
		protected RadioButton rdoCanEditCategories0				= new RadioButton(),	rdoCanEditCategories1				= new RadioButton(),	rdoCanEditCategories2				= new RadioButton();
		protected RadioButton rdoCanEditForums0					= new RadioButton(),	rdoCanEditForums1					= new RadioButton(),	rdoCanEditForums2					= new RadioButton();
		protected RadioButton rdoCanEditThreads0				= new RadioButton(),	rdoCanEditThreads1					= new RadioButton(),	rdoCanEditThreads2					= new RadioButton();
		protected RadioButton rdoCanEditPosts0					= new RadioButton(),	rdoCanEditPosts1					= new RadioButton(),	rdoCanEditPosts2					= new RadioButton();
		protected RadioButton rdoCanEditHisThreads0				= new RadioButton(),	rdoCanEditHisThreads1				= new RadioButton(),	rdoCanEditHisThreads2				= new RadioButton();
		protected RadioButton rdoCanEditHisPosts0				= new RadioButton(),	rdoCanEditHisPosts1					= new RadioButton(),	rdoCanEditHisPosts2					= new RadioButton();
		protected RadioButton rdoCanDeleteGroups0				= new RadioButton(),	rdoCanDeleteGroups1					= new RadioButton(),	rdoCanDeleteGroups2					= new RadioButton();
		protected RadioButton rdoCanDeleteCategories0			= new RadioButton(),	rdoCanDeleteCategories1				= new RadioButton(),	rdoCanDeleteCategories2				= new RadioButton();
		protected RadioButton rdoCanDeleteForums0				= new RadioButton(),	rdoCanDeleteForums1					= new RadioButton(),	rdoCanDeleteForums2					= new RadioButton();
		protected RadioButton rdoCanDeleteThreads0				= new RadioButton(),	rdoCanDeleteThreads1				= new RadioButton(),	rdoCanDeleteThreads2				= new RadioButton();
		protected RadioButton rdoCanDeletePosts0				= new RadioButton(),	rdoCanDeletePosts1					= new RadioButton(),	rdoCanDeletePosts2					= new RadioButton();
		protected RadioButton rdoCanDeleteHisThreads0			= new RadioButton(),	rdoCanDeleteHisThreads1				= new RadioButton(),	rdoCanDeleteHisThreads2				= new RadioButton();
		protected RadioButton rdoCanDeleteHisPosts0				= new RadioButton(),	rdoCanDeleteHisPosts1				= new RadioButton(),	rdoCanDeleteHisPosts2				= new RadioButton();
		protected RadioButton rdoCanManageMessageBoardSecurity0	= new RadioButton(),	rdoCanManageMessageBoardSecurity1	= new RadioButton(),	rdoCanManageMessageBoardSecurity2	= new RadioButton();
		protected RadioButton rdoCanManageGroupsSecurity0		= new RadioButton(),	rdoCanManageGroupsSecurity1			= new RadioButton(),	rdoCanManageGroupsSecurity2			= new RadioButton();
		protected RadioButton rdoCanManageCategoriesSecurity0	= new RadioButton(),	rdoCanManageCategoriesSecurity1		= new RadioButton(),	rdoCanManageCategoriesSecurity2		= new RadioButton();
		protected RadioButton rdoCanManageForumsSecurity0		= new RadioButton(),	rdoCanManageForumsSecurity1			= new RadioButton(),	rdoCanManageForumsSecurity2			= new RadioButton();
		protected RadioButton rdoCanManageThreadsSecurity0		= new RadioButton(),	rdoCanManageThreadsSecurity1		= new RadioButton(),	rdoCanManageThreadsSecurity2		= new RadioButton();
		protected RadioButton rdoCanManagePostsSecurity0		= new RadioButton(),	rdoCanManagePostsSecurity1			= new RadioButton(),	rdoCanManagePostsSecurity2			= new RadioButton();
		#endregion
		
		#region IPostBackDataHandler
		public bool LoadPostData(String postDataKey, System.Collections.Specialized.NameValueCollection values)
		{
			id = cmbUsers.SelectedValue;
			return false;
		}

		public void RaisePostDataChangedEvent()
		{

		}

		protected void Page_Init(object sender, EventArgs e)
		{
			Page.RegisterRequiresPostBack(this);
		}

		private void InitializeComponent()
		{ 
			cmdOk.Click += new EventHandler(cmdOk_Click);
			cmdCancel.Click += new EventHandler(cmdCancel_Click);
			cmdAdd.Click += new EventHandler(cmdAdd_Click);
			cmbUsers.SelectedIndexChanged += new EventHandler(cmbUsers_SelectedIndexChanged);
		}

		override protected void OnInit(EventArgs e)
		{
			InitializeComponent();
			base.OnInit(e);
		}

		#endregion

		#region CreateChildControls
		protected override void CreateChildControls() 
		{
			cmbUsers.ID = "cmbUsers";
			cmbUsers.AutoPostBack = true;

			foreach(MessageBoard.UserGroup userGroup in MessageBoard.UserGroup.GetAll())
			{
				ListItem item = new ListItem("["+userGroup.Title+"]", "g"+userGroup.Id.ToString());
				cmbUsers.Items.Add(item);
			}

			foreach(MessageBoard.User user in MessageBoard.User.GetAll())
			{

				ListItem item = new ListItem(user.DisplayName, "u"+user.Id.ToString());
				cmbUsers.Items.Add(item);
			}
			cmbUsers.SelectedValue = id;
			DisplayRole();
			cmdAdd.ID = "cmdAdd";
			cmdAdd.Text = Translate("Apply");
			cmdOk.ID = "cmdOk";
			cmdOk.Text = Translate("Ok");
			cmdCancel.ID = "cmdCancle";
			cmdCancel.Text = Translate("Cancle");
			
			// Put the contols in a table.
			HtmlTable table = new HtmlTable();
			table.Attributes.Add("width", "100%");
			HtmlTableRow tr0 = new HtmlTableRow();
			table.Controls.Add(tr0);
			HtmlTableCell td0 = new HtmlTableCell();
			tr0.Controls.Add(td0);
			td0.Attributes.Add("class", "Forum_Title1");
			td0.InnerHtml = Translate("Manage Security");

			HtmlTableRow tr01 = new HtmlTableRow();
			table.Controls.Add(tr01);
			HtmlTableCell td01 = new HtmlTableCell();
			tr01.Controls.Add(td01);
			td01.Attributes.Add("class", "Forum_Title4");

			// Table 2
			HtmlTable table2 = new HtmlTable();
			table2.Attributes.Add("width", "100%");

			// Title
			HtmlTableRow tr1 = new HtmlTableRow();
			table2.Controls.Add(tr1);
			HtmlTableCell td11 = new HtmlTableCell();
			HtmlTableCell td12 = new HtmlTableCell();
			td12.Attributes.Add("colspan", "4");
			td11.Width = "120";
			td11.InnerHtml = Translate("User")+":";
			td11.Attributes.Add("class", "Forum_Text");
			
			td12.Controls.Add(cmbUsers);
			tr1.Controls.Add(td11);
			tr1.Controls.Add(td12);
			

			// Role
			DrawRoles(table2);
			////////////////

			// Button
			HtmlTableRow tr3 = new HtmlTableRow();
			table2.Controls.Add(tr3);
			HtmlTableCell td31 = new HtmlTableCell();
			HtmlTableCell td32 = new HtmlTableCell();
			td32.Attributes.Add("colspan","4");
			td31.InnerHtml = "";
			td32.Controls.Add(cmdOk);
			td32.Controls.Add(cmdCancel);
			td32.Controls.Add(cmdAdd);
			tr3.Controls.Add(td31);
			tr3.Controls.Add(td32);

			td01.Controls.Add(table2);

			HtmlTable tableOut = new HtmlTable();
			HtmlTableRow trOut = new HtmlTableRow();
			HtmlTableCell tdOut = new HtmlTableCell();
			tableOut.BgColor = "#000000";
			tableOut.Attributes.Add("width", "100%");
			tableOut.CellPadding = 0;
			tableOut.CellSpacing = 0;
			table.CellSpacing = 1;
			tdOut.Controls.Add(table);
			trOut.Controls.Add(tdOut);
			tableOut.Controls.Add(trOut);
			Controls.Add(tableOut);
	
                  
		}
		#endregion

		public void cmbUsers_SelectedIndexChanged(Object sender, EventArgs e)
		{
			DisplayRole();
		}

		private void DisplayRole()
		{
			MessageBoard.Role role = GetRole();
			if(role!=null)
			{
				SelectRadio(role);	
				cmdAdd.Text = Translate("Apply");
			}
			else
			{
				role = new MessageBoard.Role();
				SelectRadio(role);	
				cmdAdd.Text = Translate("Create");
			}
		}

		private MessageBoard.Role GetRole()
		{
			MessageBoard.Role role;
			string str = cmbUsers.SelectedValue.Substring(0,1);		
			int id = int.Parse(cmbUsers.SelectedValue.Substring(1,cmbUsers.SelectedValue.Length-1));
			if(Group!=null)
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id), Group);
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id), Group);
				}
			}
			else if(Category!=null)
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id), Category);
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id), Category);
				}
			}
			else if(Forum!=null)
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id), Forum);
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id), Forum);
				}
			}
			else if(Thread!=null)
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id), Thread);
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id), Thread);
				}
			}
			else if(Post!=null)
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id), Post);
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id), Post);
				}
			}
			else
			{
				if(str=="g")
				{
					role = MessageBoard.Role.Get(MessageBoard.UserGroup.Get(id));
				}
				else
				{
					role = MessageBoard.Role.Get(MessageBoard.User.Get(id));
				}
			}
			return role;
		}

		private void SelectRadio(MessageBoard.Role role)
		{
			#region SelectRadio
			#region CanViewGroups
			rdoCanViewGroups0.Checked = false;
			rdoCanViewGroups1.Checked = false;
			rdoCanViewGroups2.Checked = false;
			if(role.CanViewGroups == MessageBoard.Role.Allow.AsParent)
				rdoCanViewGroups0.Checked = true;
			if(role.CanViewGroups == MessageBoard.Role.Allow.Yes)
				rdoCanViewGroups1.Checked = true;
			if(role.CanViewGroups == MessageBoard.Role.Allow.No)
				rdoCanViewGroups2.Checked = true;
			#endregion

			#region CanViewCategories
			rdoCanViewCategories0.Checked = false;
			rdoCanViewCategories1.Checked = false;
			rdoCanViewCategories2.Checked = false;
			if(role.CanViewCategories == MessageBoard.Role.Allow.AsParent)
				rdoCanViewCategories0.Checked = true;
			if(role.CanViewCategories == MessageBoard.Role.Allow.Yes)
				rdoCanViewCategories1.Checked = true;
			if(role.CanViewCategories == MessageBoard.Role.Allow.No)
				rdoCanViewCategories2.Checked = true;
			#endregion

			#region CanViewForums
			rdoCanViewForums0.Checked = false;
			rdoCanViewForums1.Checked = false;
			rdoCanViewForums2.Checked = false;
			if(role.CanViewForums == MessageBoard.Role.Allow.AsParent)
				rdoCanViewForums0.Checked = true;
			if(role.CanViewForums == MessageBoard.Role.Allow.Yes)
				rdoCanViewForums1.Checked = true;
			if(role.CanViewForums == MessageBoard.Role.Allow.No)
				rdoCanViewForums2.Checked = true;
			#endregion

			#region CanViewThreads
			rdoCanViewThreads0.Checked = false;
			rdoCanViewThreads1.Checked = false;
			rdoCanViewThreads2.Checked = false;
			if(role.CanViewThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanViewThreads0.Checked = true;
			if(role.CanViewThreads == MessageBoard.Role.Allow.Yes)
				rdoCanViewThreads1.Checked = true;
			if(role.CanViewThreads == MessageBoard.Role.Allow.No)
				rdoCanViewThreads2.Checked = true;
			#endregion

			#region CanViewPosts
			rdoCanViewPosts0.Checked = false;
			rdoCanViewPosts1.Checked = false;
			rdoCanViewPosts2.Checked = false;
			if(role.CanViewPosts == MessageBoard.Role.Allow.AsParent)
				rdoCanViewPosts0.Checked = true;
			if(role.CanViewPosts == MessageBoard.Role.Allow.Yes)
				rdoCanViewPosts1.Checked = true;
			if(role.CanViewPosts == MessageBoard.Role.Allow.No)
				rdoCanViewPosts2.Checked = true;
			#endregion

			#region CanAddGroups
			rdoCanAddGroups0.Checked = false;
			rdoCanAddGroups1.Checked = false;
			rdoCanAddGroups2.Checked = false;
			if(role.CanAddGroups == MessageBoard.Role.Allow.AsParent)
				rdoCanAddGroups0.Checked = true;
			if(role.CanAddGroups == MessageBoard.Role.Allow.Yes)
				rdoCanAddGroups1.Checked = true;
			if(role.CanAddGroups == MessageBoard.Role.Allow.No)
				rdoCanAddGroups2.Checked = true;
			#endregion

			#region CanAddCategories
			rdoCanAddCategories0.Checked = false;
			rdoCanAddCategories1.Checked = false;
			rdoCanAddCategories2.Checked = false;
			if(role.CanAddCategories == MessageBoard.Role.Allow.AsParent)
				rdoCanAddCategories0.Checked = true;
			if(role.CanAddCategories == MessageBoard.Role.Allow.Yes)
				rdoCanAddCategories1.Checked = true;
			if(role.CanAddCategories == MessageBoard.Role.Allow.No)
				rdoCanAddCategories2.Checked = true;
			#endregion

			#region CanAddForums
			rdoCanAddForums0.Checked = false;
			rdoCanAddForums1.Checked = false;
			rdoCanAddForums2.Checked = false;
			if(role.CanAddForums == MessageBoard.Role.Allow.AsParent)
				rdoCanAddForums0.Checked = true;
			if(role.CanAddForums == MessageBoard.Role.Allow.Yes)
				rdoCanAddForums1.Checked = true;
			if(role.CanAddForums == MessageBoard.Role.Allow.No)
				rdoCanAddForums2.Checked = true;
			#endregion

			#region CanAddThreads
			rdoCanAddThreads0.Checked = false;
			rdoCanAddThreads1.Checked = false;
			rdoCanAddThreads2.Checked = false;
			if(role.CanAddThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanAddThreads0.Checked = true;
			if(role.CanAddThreads == MessageBoard.Role.Allow.Yes)
				rdoCanAddThreads1.Checked = true;
			if(role.CanAddThreads == MessageBoard.Role.Allow.No)
				rdoCanAddThreads2.Checked = true;
			#endregion			

			#region CanAddPosts
			rdoCanAddPosts0.Checked = false;
			rdoCanAddPosts1.Checked = false;
			rdoCanAddPosts2.Checked = false;
			if(role.CanAddPosts == MessageBoard.Role.Allow.AsParent)
				rdoCanAddPosts0.Checked = true;
			if(role.CanAddPosts == MessageBoard.Role.Allow.Yes)
				rdoCanAddPosts1.Checked = true;
			if(role.CanAddPosts == MessageBoard.Role.Allow.No)
				rdoCanAddPosts2.Checked = true;
			#endregion			

			#region CanEditGroups
			rdoCanEditGroups0.Checked = false;
			rdoCanEditGroups1.Checked = false;
			rdoCanEditGroups2.Checked = false;
			if(role.CanEditGroups == MessageBoard.Role.Allow.AsParent)
				rdoCanEditGroups0.Checked = true;
			if(role.CanEditGroups == MessageBoard.Role.Allow.Yes)
				rdoCanEditGroups1.Checked = true;
			if(role.CanEditGroups == MessageBoard.Role.Allow.No)
				rdoCanEditGroups2.Checked = true;
			#endregion			

			#region CanEditCategories
			rdoCanEditCategories0.Checked = false;
			rdoCanEditCategories1.Checked = false;
			rdoCanEditCategories2.Checked = false;
			if(role.CanEditCategories == MessageBoard.Role.Allow.AsParent)
				rdoCanEditCategories0.Checked = true;
			if(role.CanEditCategories == MessageBoard.Role.Allow.Yes)
				rdoCanEditCategories1.Checked = true;
			if(role.CanEditCategories == MessageBoard.Role.Allow.No)
				rdoCanEditCategories2.Checked = true;
			#endregion			

			#region CanEditForums
			rdoCanEditForums0.Checked = false;
			rdoCanEditForums1.Checked = false;
			rdoCanEditForums2.Checked = false;
			if(role.CanEditForums == MessageBoard.Role.Allow.AsParent)
				rdoCanEditForums0.Checked = true;
			if(role.CanEditForums == MessageBoard.Role.Allow.Yes)
				rdoCanEditForums1.Checked = true;
			if(role.CanEditForums == MessageBoard.Role.Allow.No)
				rdoCanEditForums2.Checked = true;
			#endregion			

			#region CanEditThreads
			rdoCanEditThreads0.Checked = false;
			rdoCanEditThreads1.Checked = false;
			rdoCanEditThreads2.Checked = false;
			if(role.CanEditThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanEditThreads0.Checked = true;
			if(role.CanEditThreads == MessageBoard.Role.Allow.Yes)
				rdoCanEditThreads1.Checked = true;
			if(role.CanEditThreads == MessageBoard.Role.Allow.No)
				rdoCanEditThreads2.Checked = true;
			#endregion			

			#region CanEditPosts
			rdoCanEditPosts0.Checked = false;
			rdoCanEditPosts1.Checked = false;
			rdoCanEditPosts2.Checked = false;
			if(role.CanEditPosts == MessageBoard.Role.Allow.AsParent)
				rdoCanEditPosts0.Checked = true;
			if(role.CanEditPosts == MessageBoard.Role.Allow.Yes)
				rdoCanEditPosts1.Checked = true;
			if(role.CanEditPosts == MessageBoard.Role.Allow.No)
				rdoCanEditPosts2.Checked = true;
			#endregion			

			#region CanEditHisThreads
			rdoCanEditHisThreads0.Checked = false;
			rdoCanEditHisThreads1.Checked = false;
			rdoCanEditHisThreads2.Checked = false;
			if(role.CanEditHisThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanEditHisThreads0.Checked = true;
			if(role.CanEditHisThreads == MessageBoard.Role.Allow.Yes)
				rdoCanEditHisThreads1.Checked = true;
			if(role.CanEditHisThreads == MessageBoard.Role.Allow.No)
				rdoCanEditHisThreads2.Checked = true;
			#endregion			

			#region CanEditHisPosts
			rdoCanEditHisPosts0.Checked = false;
			rdoCanEditHisPosts1.Checked = false;
			rdoCanEditHisPosts2.Checked = false;
			if(role.CanEditHisPosts == MessageBoard.Role.Allow.AsParent)
				rdoCanEditHisPosts0.Checked = true;
			if(role.CanEditHisPosts == MessageBoard.Role.Allow.Yes)
				rdoCanEditHisPosts1.Checked = true;
			if(role.CanEditHisPosts == MessageBoard.Role.Allow.No)
				rdoCanEditHisPosts2.Checked = true;
			#endregion			

			#region CanDeleteGroups
			rdoCanDeleteGroups0.Checked = false;
			rdoCanDeleteGroups1.Checked = false;
			rdoCanDeleteGroups2.Checked = false;
			if(role.CanDeleteGroups == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteGroups0.Checked = true;
			if(role.CanDeleteGroups == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteGroups1.Checked = true;
			if(role.CanDeleteGroups == MessageBoard.Role.Allow.No)
				rdoCanDeleteGroups2.Checked = true;
			#endregion			
			
			#region CanDeleteCategories
			rdoCanDeleteCategories0.Checked = false;
			rdoCanDeleteCategories1.Checked = false;
			rdoCanDeleteCategories2.Checked = false;
			if(role.CanDeleteCategories == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteCategories0.Checked = true;
			if(role.CanDeleteCategories == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteCategories1.Checked = true;
			if(role.CanDeleteCategories == MessageBoard.Role.Allow.No)
				rdoCanDeleteCategories2.Checked = true;
			#endregion			
			
			#region CanDeleteForums
			rdoCanDeleteForums0.Checked = false;
			rdoCanDeleteForums1.Checked = false;
			rdoCanDeleteForums2.Checked = false;
			if(role.CanDeleteForums == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteForums0.Checked = true;
			if(role.CanDeleteForums == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteForums1.Checked = true;
			if(role.CanDeleteForums == MessageBoard.Role.Allow.No)
				rdoCanDeleteForums2.Checked = true;
			#endregion			
			
			#region CanDeleteThreads
			rdoCanDeleteThreads0.Checked = false;
			rdoCanDeleteThreads1.Checked = false;
			rdoCanDeleteThreads2.Checked = false;
			if(role.CanDeleteThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteThreads0.Checked = true;
			if(role.CanDeleteThreads == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteThreads1.Checked = true;
			if(role.CanDeleteThreads == MessageBoard.Role.Allow.No)
				rdoCanDeleteThreads2.Checked = true;
			#endregion			
			
			#region CanDeletePosts
			rdoCanDeletePosts0.Checked = false;
			rdoCanDeletePosts1.Checked = false;
			rdoCanDeletePosts2.Checked = false;
			if(role.CanDeletePosts == MessageBoard.Role.Allow.AsParent)
				rdoCanDeletePosts0.Checked = true;
			if(role.CanDeletePosts == MessageBoard.Role.Allow.Yes)
				rdoCanDeletePosts1.Checked = true;
			if(role.CanDeletePosts == MessageBoard.Role.Allow.No)
				rdoCanDeletePosts2.Checked = true;
			#endregion
			
			#region CanDeleteHisThreads
			rdoCanDeleteHisThreads0.Checked = false;
			rdoCanDeleteHisThreads1.Checked = false;
			rdoCanDeleteHisThreads2.Checked = false;
			if(role.CanDeleteHisThreads == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteHisThreads0.Checked = true;
			if(role.CanDeleteHisThreads == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteHisThreads1.Checked = true;
			if(role.CanDeleteHisThreads == MessageBoard.Role.Allow.No)
				rdoCanDeleteHisThreads2.Checked = true;
			#endregion
			
			#region CanDeleteHisPosts
			rdoCanDeleteHisPosts0.Checked = false;
			rdoCanDeleteHisPosts1.Checked = false;
			rdoCanDeleteHisPosts2.Checked = false;
			if(role.CanDeleteHisPosts == MessageBoard.Role.Allow.AsParent)
				rdoCanDeleteHisPosts0.Checked = true;
			if(role.CanDeleteHisPosts == MessageBoard.Role.Allow.Yes)
				rdoCanDeleteHisPosts1.Checked = true;
			if(role.CanDeleteHisPosts == MessageBoard.Role.Allow.No)
				rdoCanDeleteHisPosts2.Checked = true;
			#endregion
			
			if(Group==null)
			{
				#region CanManageMessageBoardSecurity
				rdoCanManageMessageBoardSecurity0.Checked = false;
				rdoCanManageMessageBoardSecurity1.Checked = false;
				rdoCanManageMessageBoardSecurity2.Checked = false;
				if(role.CanManageMessageBoardSecurity == MessageBoard.Role.Allow.AsParent)
					rdoCanManageMessageBoardSecurity0.Checked = true;
				if(role.CanManageMessageBoardSecurity == MessageBoard.Role.Allow.Yes)
					rdoCanManageMessageBoardSecurity1.Checked = true;
				if(role.CanManageMessageBoardSecurity == MessageBoard.Role.Allow.No)
					rdoCanManageMessageBoardSecurity2.Checked = true;
				#endregion
			}

			#region CanManageGroupsSecurity
			rdoCanManageGroupsSecurity0.Checked = false;
			rdoCanManageGroupsSecurity1.Checked = false;
			rdoCanManageGroupsSecurity2.Checked = false;
			if(role.CanManageGroupsSecurity == MessageBoard.Role.Allow.AsParent)
				rdoCanManageGroupsSecurity0.Checked = true;
			if(role.CanManageGroupsSecurity == MessageBoard.Role.Allow.Yes)
				rdoCanManageGroupsSecurity1.Checked = true;
			if(role.CanManageGroupsSecurity == MessageBoard.Role.Allow.No)
				rdoCanManageGroupsSecurity2.Checked = true;
			#endregion
			
			#region CanManageCategoriesSecurity
			rdoCanManageCategoriesSecurity0.Checked = false;
			rdoCanManageCategoriesSecurity1.Checked = false;
			rdoCanManageCategoriesSecurity2.Checked = false;
			if(role.CanManageCategoriesSecurity == MessageBoard.Role.Allow.AsParent)
				rdoCanManageCategoriesSecurity0.Checked = true;
			if(role.CanManageCategoriesSecurity == MessageBoard.Role.Allow.Yes)
				rdoCanManageCategoriesSecurity1.Checked = true;
			if(role.CanManageCategoriesSecurity == MessageBoard.Role.Allow.No)
				rdoCanManageCategoriesSecurity2.Checked = true;
			#endregion
			
			#region CanManageForumsSecurity
			rdoCanManageForumsSecurity0.Checked = false;
			rdoCanManageForumsSecurity1.Checked = false;
			rdoCanManageForumsSecurity2.Checked = false;
			if(role.CanManageForumsSecurity == MessageBoard.Role.Allow.AsParent)
				rdoCanManageForumsSecurity0.Checked = true;
			if(role.CanManageForumsSecurity == MessageBoard.Role.Allow.Yes)
				rdoCanManageForumsSecurity1.Checked = true;
			if(role.CanManageForumsSecurity == MessageBoard.Role.Allow.No)
				rdoCanManageForumsSecurity2.Checked = true;
			#endregion
			
			#region CanManageThreadsSecurity
			rdoCanManageThreadsSecurity0.Checked = false;
			rdoCanManageThreadsSecurity1.Checked = false;
			rdoCanManageThreadsSecurity2.Checked = false;
			if(role.CanManageThreadsSecurity == MessageBoard.Role.Allow.AsParent)
				rdoCanManageThreadsSecurity0.Checked = true;
			if(role.CanManageThreadsSecurity == MessageBoard.Role.Allow.Yes)
				rdoCanManageThreadsSecurity1.Checked = true;
			if(role.CanManageThreadsSecurity == MessageBoard.Role.Allow.No)
				rdoCanManageThreadsSecurity2.Checked = true;
			#endregion
			
			#region CanManagePostsSecurity
			rdoCanManagePostsSecurity0.Checked = false;
			rdoCanManagePostsSecurity1.Checked = false;
			rdoCanManagePostsSecurity2.Checked = false;
			if(role.CanManagePostsSecurity == MessageBoard.Role.Allow.AsParent)
				rdoCanManagePostsSecurity0.Checked = true;
			if(role.CanManagePostsSecurity == MessageBoard.Role.Allow.Yes)
				rdoCanManagePostsSecurity1.Checked = true;
			if(role.CanManagePostsSecurity == MessageBoard.Role.Allow.No)
				rdoCanManagePostsSecurity2.Checked = true;
			#endregion
			#endregion			
		}

		public void cmdAdd_Click(Object sender, EventArgs e)
		{
			UpdateRoles(GetRole());			
		}

		public void cmdOk_Click(Object sender, EventArgs e)
		{
			UpdateRoles(GetRole());	
			this.Page.Response.Redirect(urlAfter);
		}

		public void cmdCancel_Click(Object sender, EventArgs e)
		{
			this.Page.Response.Redirect(urlAfter);
		}

		private void UpdateRoles(MessageBoard.Role role)
		{

			if(role==null)
			{
				role = new MessageBoard.Role();
			}

			#region Update Roles
			
			if(Group==null && Category==null && Forum==null && Thread==null && Post==null)
			{
				#region CanManageMessageBoardSecurity
				if(rdoCanManageMessageBoardSecurity0.Checked)
					role.CanManageMessageBoardSecurity = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanManageMessageBoardSecurity1.Checked)
					role.CanManageMessageBoardSecurity = MessageBoard.Role.Allow.Yes;
				else if(rdoCanManageMessageBoardSecurity2.Checked)
					role.CanManageMessageBoardSecurity = MessageBoard.Role.Allow.No;
				#endregion
			}
			if(Category==null && Forum==null && Thread==null && Post==null)
			{
				#region CanViewGroups
				if(rdoCanViewGroups0.Checked)
					role.CanViewGroups = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanViewGroups1.Checked)
					role.CanViewGroups = MessageBoard.Role.Allow.Yes;
				else if(rdoCanViewGroups2.Checked)
					role.CanViewGroups = MessageBoard.Role.Allow.No;
				#endregion

				#region CanAddGroups
				if(rdoCanAddGroups0.Checked)
					role.CanAddGroups = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanAddGroups1.Checked)
					role.CanAddGroups = MessageBoard.Role.Allow.Yes;
				else if(rdoCanAddGroups2.Checked)
					role.CanAddGroups = MessageBoard.Role.Allow.No;
				#endregion

				#region CanEditGroups
				if(rdoCanEditGroups0.Checked)
					role.CanEditGroups = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanEditGroups1.Checked)
					role.CanEditGroups = MessageBoard.Role.Allow.Yes;
				else if(rdoCanEditGroups2.Checked)
					role.CanEditGroups = MessageBoard.Role.Allow.No;
				#endregion

				#region CanDeleteGroups
				if(rdoCanDeleteGroups0.Checked)
					role.CanDeleteGroups = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanDeleteGroups1.Checked)
					role.CanDeleteGroups = MessageBoard.Role.Allow.Yes;
				else if(rdoCanDeleteGroups2.Checked)
					role.CanDeleteGroups = MessageBoard.Role.Allow.No;
				#endregion

				#region CanManageGroupsSecurity
				if(rdoCanManageGroupsSecurity0.Checked)
					role.CanManageGroupsSecurity = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanManageGroupsSecurity1.Checked)
					role.CanManageGroupsSecurity = MessageBoard.Role.Allow.Yes;
				else if(rdoCanManageGroupsSecurity2.Checked)
					role.CanManageGroupsSecurity = MessageBoard.Role.Allow.No;
				#endregion
			}
			if(Forum==null && Thread==null && Post==null)
			{
				#region CanViewCategories
				if(rdoCanViewCategories0.Checked)
					role.CanViewCategories = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanViewCategories1.Checked)
					role.CanViewCategories = MessageBoard.Role.Allow.Yes;
				else if(rdoCanViewCategories2.Checked)
					role.CanViewCategories = MessageBoard.Role.Allow.No;
				#endregion

				#region CanAddCategories
				if(rdoCanAddCategories0.Checked)
					role.CanAddCategories = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanAddCategories1.Checked)
					role.CanAddCategories = MessageBoard.Role.Allow.Yes;
				else if(rdoCanAddCategories2.Checked)
					role.CanAddCategories = MessageBoard.Role.Allow.No;
				#endregion

				#region CanEditCategories
				if(rdoCanEditCategories0.Checked)
					role.CanEditCategories = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanEditCategories1.Checked)
					role.CanEditCategories = MessageBoard.Role.Allow.Yes;
				else if(rdoCanEditCategories2.Checked)
					role.CanEditCategories = MessageBoard.Role.Allow.No;
				#endregion

				#region CanDeleteCategories
				if(rdoCanDeleteCategories0.Checked)
					role.CanDeleteCategories = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanDeleteCategories1.Checked)
					role.CanDeleteCategories = MessageBoard.Role.Allow.Yes;
				else if(rdoCanDeleteCategories2.Checked)
					role.CanDeleteCategories = MessageBoard.Role.Allow.No;
				#endregion

				#region CanManageCategoriesSecurity
				if(rdoCanManageCategoriesSecurity0.Checked)
					role.CanManageCategoriesSecurity = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanManageCategoriesSecurity1.Checked)
					role.CanManageCategoriesSecurity = MessageBoard.Role.Allow.Yes;
				else if(rdoCanManageCategoriesSecurity2.Checked)
					role.CanManageCategoriesSecurity = MessageBoard.Role.Allow.No;
				#endregion
			}
			if(Thread==null && Post==null)
			{
				#region CanViewForums
				if(rdoCanViewForums0.Checked)
					role.CanViewForums = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanViewForums1.Checked)
					role.CanViewForums = MessageBoard.Role.Allow.Yes;
				else if(rdoCanViewForums2.Checked)
					role.CanViewForums = MessageBoard.Role.Allow.No;
				#endregion

				#region CanAddForums
				if(rdoCanAddForums0.Checked)
					role.CanAddForums = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanAddForums1.Checked)
					role.CanAddForums = MessageBoard.Role.Allow.Yes;
				else if(rdoCanAddForums2.Checked)
					role.CanAddForums = MessageBoard.Role.Allow.No;
				#endregion

				#region CanEditForums
				if(rdoCanEditForums0.Checked)
					role.CanEditForums = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanEditForums1.Checked)
					role.CanEditForums = MessageBoard.Role.Allow.Yes;
				else if(rdoCanEditForums2.Checked)
					role.CanEditForums = MessageBoard.Role.Allow.No;
				#endregion

				#region CanDeleteForums
				if(rdoCanDeleteForums0.Checked)
					role.CanDeleteForums = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanDeleteForums1.Checked)
					role.CanDeleteForums = MessageBoard.Role.Allow.Yes;
				else if(rdoCanDeleteForums2.Checked)
					role.CanDeleteForums = MessageBoard.Role.Allow.No;
				#endregion

				#region CanManageForumsSecurity
				if(rdoCanManageForumsSecurity0.Checked)
					role.CanManageForumsSecurity = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanManageForumsSecurity1.Checked)
					role.CanManageForumsSecurity = MessageBoard.Role.Allow.Yes;
				else if(rdoCanManageForumsSecurity2.Checked)
					role.CanManageForumsSecurity = MessageBoard.Role.Allow.No;
				#endregion
			}
			if(Post==null)
			{
				#region CanViewThreads
				if(rdoCanViewThreads0.Checked)
					role.CanViewThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanViewThreads1.Checked)
					role.CanViewThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanViewThreads2.Checked)
					role.CanViewThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanAddThreads
				if(rdoCanAddThreads0.Checked)
					role.CanAddThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanAddThreads1.Checked)
					role.CanAddThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanAddThreads2.Checked)
					role.CanAddThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanEditThreads
				if(rdoCanEditThreads0.Checked)
					role.CanEditThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanEditThreads1.Checked)
					role.CanEditThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanEditThreads2.Checked)
					role.CanEditThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanEditHisThreads
				if(rdoCanEditHisThreads0.Checked)
					role.CanEditHisThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanEditHisThreads1.Checked)
					role.CanEditHisThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanEditHisThreads2.Checked)
					role.CanEditHisThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanDeleteThreads
				if(rdoCanDeleteThreads0.Checked)
					role.CanDeleteThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanDeleteThreads1.Checked)
					role.CanDeleteThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanDeleteThreads2.Checked)
					role.CanDeleteThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanDeleteHisThreads
				if(rdoCanDeleteHisThreads0.Checked)
					role.CanDeleteHisThreads = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanDeleteHisThreads1.Checked)
					role.CanDeleteHisThreads = MessageBoard.Role.Allow.Yes;
				else if(rdoCanDeleteHisThreads2.Checked)
					role.CanDeleteHisThreads = MessageBoard.Role.Allow.No;
				#endregion

				#region CanManageThreadsSecurity
				if(rdoCanManageThreadsSecurity0.Checked)
					role.CanManageThreadsSecurity = MessageBoard.Role.Allow.AsParent;
				else if(rdoCanManageThreadsSecurity1.Checked)
					role.CanManageThreadsSecurity = MessageBoard.Role.Allow.Yes;
				else if(rdoCanManageThreadsSecurity2.Checked)
					role.CanManageThreadsSecurity = MessageBoard.Role.Allow.No;
				#endregion
			}

			#region CanViewPosts
			if(rdoCanViewPosts0.Checked)
				role.CanViewPosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanViewPosts1.Checked)
				role.CanViewPosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanViewPosts2.Checked)
				role.CanViewPosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanAddPosts
			if(rdoCanAddPosts0.Checked)
				role.CanAddPosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanAddPosts1.Checked)
				role.CanAddPosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanAddPosts2.Checked)
				role.CanAddPosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanEditPosts
			if(rdoCanEditPosts0.Checked)
				role.CanEditPosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanEditPosts1.Checked)
				role.CanEditPosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanEditPosts2.Checked)
				role.CanEditPosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanEditHisPosts
			if(rdoCanEditHisPosts0.Checked)
				role.CanEditHisPosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanEditHisPosts1.Checked)
				role.CanEditHisPosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanEditHisPosts2.Checked)
				role.CanEditHisPosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanDeletePosts
			if(rdoCanDeletePosts0.Checked)
				role.CanDeletePosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanDeletePosts1.Checked)
				role.CanDeletePosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanDeletePosts2.Checked)
				role.CanDeletePosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanDeleteHisPosts
			if(rdoCanDeleteHisPosts0.Checked)
				role.CanDeleteHisPosts = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanDeleteHisPosts1.Checked)
				role.CanDeleteHisPosts = MessageBoard.Role.Allow.Yes;
			else if(rdoCanDeleteHisPosts2.Checked)
				role.CanDeleteHisPosts = MessageBoard.Role.Allow.No;
			#endregion

			#region CanManagePostsSecurity
			if(rdoCanManagePostsSecurity0.Checked)
				role.CanManagePostsSecurity = MessageBoard.Role.Allow.AsParent;
			else if(rdoCanManagePostsSecurity1.Checked)
				role.CanManagePostsSecurity = MessageBoard.Role.Allow.Yes;
			else if(rdoCanManagePostsSecurity2.Checked)
				role.CanManagePostsSecurity = MessageBoard.Role.Allow.No;
			#endregion

			#endregion

			if(role.Id!=0)
			{
				role.Update();	
			}
			else
			{
				string str = cmbUsers.SelectedValue.Substring(0,1);		
				int id = int.Parse(cmbUsers.SelectedValue.Substring(1,cmbUsers.SelectedValue.Length-1));
				if(Group!=null)
				{
					role.Group = Group;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				else if(Category!=null)
				{
					role.Category = Category;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				else if(Forum!=null)
				{
					role.Forum = Forum;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				else if(Thread!=null)
				{
					role.Thread = Thread;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				else if(Post!=null)
				{
					role.Post = Post;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				else
				{
					role.TheMessageBoard = true;
					if(str=="g")
					{
						role.UserGroup = MessageBoard.UserGroup.Get(id);
					}
					else
					{
						role.User = MessageBoard.User.Get(id);
					}
				}
				role.Insert();
			}
		}

		private void DrawRoles(HtmlTable table)
		{

			HtmlTable table2 = new HtmlTable();

			HtmlTable tableOut = new HtmlTable();
			HtmlTableRow trOut = new HtmlTableRow();
			HtmlTableCell tdOut = new HtmlTableCell();
			tableOut.BgColor = "#000000";
			tableOut.Attributes.Add("align", "center");
			tableOut.CellPadding = 0;
			tableOut.CellSpacing = 0;

			table2.CellSpacing = 1;
			tdOut.Controls.Add(table2);
			trOut.Controls.Add(tdOut);
			tableOut.Controls.Add(trOut);

			

			#region head
			HtmlTableRow tr2 = new HtmlTableRow();
			table2.Controls.Add(tr2);
			HtmlTableCell td21 = new HtmlTableCell();
			HtmlTableCell td22 = new HtmlTableCell();
			HtmlTableCell td23 = new HtmlTableCell();
			HtmlTableCell td24 = new HtmlTableCell();
			td21.Attributes.Add("class", "Forum_Title1");
			td21.Attributes.Add("vAlign", "top");
		
			td22.Attributes.Add("class", "Forum_Title1");
			td23.Attributes.Add("class", "Forum_Title1");
			td24.Attributes.Add("class", "Forum_Title1");

			td22.InnerHtml = Translate("Parent");
			td23.InnerHtml = Translate("Allow");
			td24.InnerHtml = Translate("Deny");

			td22.Width = "50"; td22.Align = "center";
			td23.Width = "50"; td23.Align = "center";
			td24.Width = "50"; td24.Align = "center";

			tr2.Controls.Add(td21);
			tr2.Controls.Add(td22);
			tr2.Controls.Add(td23);
			tr2.Controls.Add(td24);
			#endregion

			#region Table

			if(Group==null && Category==null && Forum==null && Thread==null && Post==null)
			{
				HtmlTableRow trMB = new HtmlTableRow();
				HtmlTableCell tdMB = new HtmlTableCell();
				tdMB.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Permissions")+":</span>";
				tdMB.Attributes.Add("class", "Forum_Title3");
				tdMB.Attributes.Add("colspan", "4");
				trMB.Controls.Add(tdMB);				
				table2.Controls.Add(trMB);

				#region CanManageMessageBoardSecurity
				HtmlTableRow trCanManageMessageBoardSecurity = new HtmlTableRow();
				HtmlTableCell tdCanManageMessageBoardSecurity1 = new HtmlTableCell();
				tdCanManageMessageBoardSecurity1.InnerHtml = "<nobr>"+Translate("CanManageMessageBoardSecurity")+":</nobr>";
				trCanManageMessageBoardSecurity.Controls.Add(tdCanManageMessageBoardSecurity1);
				HtmlTableCell tdCanManageMessageBoardSecurity2 = new HtmlTableCell();
				rdoCanManageMessageBoardSecurity0.ID = "rdoCanManageMessageBoardSecurity0";
				rdoCanManageMessageBoardSecurity0.GroupName = "CanManageMessageBoardSecurity";
				tdCanManageMessageBoardSecurity2.Controls.Add(rdoCanManageMessageBoardSecurity0);
				tdCanManageMessageBoardSecurity2.Align = "center";
				trCanManageMessageBoardSecurity.Controls.Add(tdCanManageMessageBoardSecurity2);
				HtmlTableCell tdCanManageMessageBoardSecurity3 = new HtmlTableCell();
				rdoCanManageMessageBoardSecurity1.ID = "rdoCanManageMessageBoardSecurity1";
				rdoCanManageMessageBoardSecurity1.GroupName = "CanManageMessageBoardSecurity";
				tdCanManageMessageBoardSecurity3.Controls.Add(rdoCanManageMessageBoardSecurity1);
				tdCanManageMessageBoardSecurity3.Align = "center";
				trCanManageMessageBoardSecurity.Controls.Add(tdCanManageMessageBoardSecurity3);
				HtmlTableCell tdCanManageMessageBoardSecurity4 = new HtmlTableCell();
				rdoCanManageMessageBoardSecurity2.ID = "rdoCanManageMessageBoardSecurity2";
				rdoCanManageMessageBoardSecurity2.GroupName = "CanManageMessageBoardSecurity";
				tdCanManageMessageBoardSecurity4.Controls.Add(rdoCanManageMessageBoardSecurity2);
				tdCanManageMessageBoardSecurity4.Align = "center";
				trCanManageMessageBoardSecurity.Controls.Add(tdCanManageMessageBoardSecurity4);
				trCanManageMessageBoardSecurity.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanManageMessageBoardSecurity);
				#endregion
			}
			if(Category==null && Forum==null && Thread==null && Post==null)
			{
				HtmlTableRow trGroups = new HtmlTableRow();
				HtmlTableCell tdGroups = new HtmlTableCell();
				tdGroups.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Groups Permissions")+":</span>";
				tdGroups.Attributes.Add("class", "Forum_Title3");
				tdGroups.Attributes.Add("colspan", "4");
				trGroups.Controls.Add(tdGroups);				
				table2.Controls.Add(trGroups);

				#region CanViewGroups
				HtmlTableRow trCanViewGroups = new HtmlTableRow();
				HtmlTableCell tdCanViewGroups1 = new HtmlTableCell();
				tdCanViewGroups1.InnerHtml = "<nobr>"+Translate("Can View Groups")+":</nobr>";
				trCanViewGroups.Controls.Add(tdCanViewGroups1);
				HtmlTableCell tdCanViewGroups2 = new HtmlTableCell();
				rdoCanViewGroups0.ID = "rdoCanViewGroups0";
				rdoCanViewGroups0.GroupName = "CanViewGroups";
				tdCanViewGroups2.Controls.Add(rdoCanViewGroups0);
				tdCanViewGroups2.Align = "center";
				trCanViewGroups.Controls.Add(tdCanViewGroups2);
				HtmlTableCell tdCanViewGroups3 = new HtmlTableCell();
				rdoCanViewGroups1.ID = "rdoCanViewGroups1";
				rdoCanViewGroups1.GroupName = "CanViewGroups";
				tdCanViewGroups3.Controls.Add(rdoCanViewGroups1);
				tdCanViewGroups3.Align = "center";
				trCanViewGroups.Controls.Add(tdCanViewGroups3);			
				HtmlTableCell tdCanViewGroups4 = new HtmlTableCell();
				rdoCanViewGroups2.ID = "rdoCanViewGroups2";
				rdoCanViewGroups2.GroupName = "CanViewGroups";
				tdCanViewGroups4.Controls.Add(rdoCanViewGroups2);
				tdCanViewGroups4.Align = "center";
				trCanViewGroups.Controls.Add(tdCanViewGroups4);
				trCanViewGroups.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanViewGroups);
				#endregion
				
				#region CanAddGroups
				HtmlTableRow trCanAddGroups = new HtmlTableRow();
				HtmlTableCell tdCanAddGroups1 = new HtmlTableCell();
				tdCanAddGroups1.InnerHtml = "<nobr>"+Translate("Can Add Groups")+":</nobr>";
				trCanAddGroups.Controls.Add(tdCanAddGroups1);
				HtmlTableCell tdCanAddGroups2 = new HtmlTableCell();
				rdoCanAddGroups0.ID = "rdoCanAddGroups0";
				rdoCanAddGroups0.GroupName = "CanAddGroups";
				tdCanAddGroups2.Controls.Add(rdoCanAddGroups0);
				tdCanAddGroups2.Align = "center";
				trCanAddGroups.Controls.Add(tdCanAddGroups2);
				HtmlTableCell tdCanAddGroups3 = new HtmlTableCell();
				rdoCanAddGroups1.ID = "rdoCanAddGroups1";
				rdoCanAddGroups1.GroupName = "CanAddGroups";
				tdCanAddGroups3.Controls.Add(rdoCanAddGroups1);
				tdCanAddGroups3.Align = "center";
				trCanAddGroups.Controls.Add(tdCanAddGroups3);
				HtmlTableCell tdCanAddGroups4 = new HtmlTableCell();
				rdoCanAddGroups2.ID = "rdoCanAddGroups2";
				rdoCanAddGroups2.GroupName = "CanAddGroups";
				tdCanAddGroups4.Controls.Add(rdoCanAddGroups2);
				tdCanAddGroups4.Align = "center";
				trCanAddGroups.Controls.Add(tdCanAddGroups4);
				trCanAddGroups.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanAddGroups);
				#endregion

				#region CanEditGroups
				HtmlTableRow trCanEditGroups = new HtmlTableRow();
				HtmlTableCell tdCanEditGroups1 = new HtmlTableCell();
				tdCanEditGroups1.InnerHtml = "<nobr>"+Translate("CanEditGroups")+":</nobr>";
				trCanEditGroups.Controls.Add(tdCanEditGroups1);
				HtmlTableCell tdCanEditGroups2 = new HtmlTableCell();
				rdoCanEditGroups0.ID = "rdoCanEditGroups0";
				rdoCanEditGroups0.GroupName = "CanEditGroups";
				tdCanEditGroups2.Controls.Add(rdoCanEditGroups0);
				tdCanEditGroups2.Align = "center";
				trCanEditGroups.Controls.Add(tdCanEditGroups2);
				HtmlTableCell tdCanEditGroups3 = new HtmlTableCell();
				rdoCanEditGroups1.ID = "rdoCanEditGroups1";
				rdoCanEditGroups1.GroupName = "CanEditGroups";
				tdCanEditGroups3.Controls.Add(rdoCanEditGroups1);
				tdCanEditGroups3.Align = "center";
				trCanEditGroups.Controls.Add(tdCanEditGroups3);
				HtmlTableCell tdCanEditGroups4 = new HtmlTableCell();
				rdoCanEditGroups2.ID = "rdoCanEditGroups2";
				rdoCanEditGroups2.GroupName = "CanEditGroups";
				tdCanEditGroups4.Controls.Add(rdoCanEditGroups2);
				tdCanEditGroups4.Align = "center";
				trCanEditGroups.Controls.Add(tdCanEditGroups4);
				trCanEditGroups.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanEditGroups);
				#endregion

				#region CanDeleteGroups
				HtmlTableRow trCanDeleteGroups = new HtmlTableRow();
				HtmlTableCell tdCanDeleteGroups1 = new HtmlTableCell();
				tdCanDeleteGroups1.InnerHtml = "<nobr>"+Translate("CanDeleteGroups")+":</nobr>";
				trCanDeleteGroups.Controls.Add(tdCanDeleteGroups1);
				HtmlTableCell tdCanDeleteGroups2 = new HtmlTableCell();
				rdoCanDeleteGroups0.ID = "rdoCanDeleteGroups0";
				rdoCanDeleteGroups0.GroupName = "CanDeleteGroups";
				tdCanDeleteGroups2.Controls.Add(rdoCanDeleteGroups0);
				tdCanDeleteGroups2.Align = "center";
				trCanDeleteGroups.Controls.Add(tdCanDeleteGroups2);
				HtmlTableCell tdCanDeleteGroups3 = new HtmlTableCell();
				rdoCanDeleteGroups1.ID = "rdoCanDeleteGroups1";
				rdoCanDeleteGroups1.GroupName = "CanDeleteGroups";
				tdCanDeleteGroups3.Controls.Add(rdoCanDeleteGroups1);
				tdCanDeleteGroups3.Align = "center";
				trCanDeleteGroups.Controls.Add(tdCanDeleteGroups3);
				HtmlTableCell tdCanDeleteGroups4 = new HtmlTableCell();
				rdoCanDeleteGroups2.ID = "rdoCanDeleteGroups2";
				rdoCanDeleteGroups2.GroupName = "CanDeleteGroups";
				tdCanDeleteGroups4.Controls.Add(rdoCanDeleteGroups2);
				tdCanDeleteGroups4.Align = "center";
				trCanDeleteGroups.Controls.Add(tdCanDeleteGroups4);
				trCanDeleteGroups.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanDeleteGroups);
				#endregion

				#region CanManageGroupsSecurity
				HtmlTableRow trCanManageGroupsSecurity = new HtmlTableRow();
				HtmlTableCell tdCanManageGroupsSecurity1 = new HtmlTableCell();
				tdCanManageGroupsSecurity1.InnerHtml = "<nobr>"+Translate("CanManageGroupsSecurity")+":</nobr>";
				trCanManageGroupsSecurity.Controls.Add(tdCanManageGroupsSecurity1);
				HtmlTableCell tdCanManageGroupsSecurity2 = new HtmlTableCell();
				rdoCanManageGroupsSecurity0.ID = "rdoCanManageGroupsSecurity0";
				rdoCanManageGroupsSecurity0.GroupName = "CanManageGroupsSecurity";
				tdCanManageGroupsSecurity2.Controls.Add(rdoCanManageGroupsSecurity0);
				tdCanManageGroupsSecurity2.Align = "center";
				trCanManageGroupsSecurity.Controls.Add(tdCanManageGroupsSecurity2);
				HtmlTableCell tdCanManageGroupsSecurity3 = new HtmlTableCell();
				rdoCanManageGroupsSecurity1.ID = "rdoCanManageGroupsSecurity1";
				rdoCanManageGroupsSecurity1.GroupName = "CanManageGroupsSecurity";
				tdCanManageGroupsSecurity3.Controls.Add(rdoCanManageGroupsSecurity1);
				tdCanManageGroupsSecurity3.Align = "center";
				trCanManageGroupsSecurity.Controls.Add(tdCanManageGroupsSecurity3);
				HtmlTableCell tdCanManageGroupsSecurity4 = new HtmlTableCell();
				rdoCanManageGroupsSecurity2.ID = "rdoCanManageGroupsSecurity2";
				rdoCanManageGroupsSecurity2.GroupName = "CanManageGroupsSecurity";
				tdCanManageGroupsSecurity4.Controls.Add(rdoCanManageGroupsSecurity2);
				tdCanManageGroupsSecurity4.Align = "center";
				trCanManageGroupsSecurity.Controls.Add(tdCanManageGroupsSecurity4);
				trCanManageGroupsSecurity.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanManageGroupsSecurity);
				#endregion
			}
			if(Forum==null && Thread==null && Post==null)
			{
				HtmlTableRow trCategories = new HtmlTableRow();
				HtmlTableCell tdCategories = new HtmlTableCell();
				tdCategories.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Categories Permissions")+":</span>";
				tdCategories.Attributes.Add("class", "Forum_Title2");
				tdCategories.Attributes.Add("colspan", "4");
				trCategories.Controls.Add(tdCategories);				
				table2.Controls.Add(trCategories);

				#region CanViewCategories
				HtmlTableRow trCanViewCategories = new HtmlTableRow();
				HtmlTableCell tdCanViewCategories1 = new HtmlTableCell();
				tdCanViewCategories1.InnerHtml = "<nobr>"+Translate("Can View Categories")+":</nobr>";
				trCanViewCategories.Controls.Add(tdCanViewCategories1);
				HtmlTableCell tdCanViewCategories2 = new HtmlTableCell();
				rdoCanViewCategories0.ID = "rdoCanViewCategories0";
				rdoCanViewCategories0.GroupName = "CanViewCategories";
				tdCanViewCategories2.Controls.Add(rdoCanViewCategories0);
				tdCanViewCategories2.Align = "center";
				trCanViewCategories.Controls.Add(tdCanViewCategories2);
				HtmlTableCell tdCanViewCategories3 = new HtmlTableCell();
				rdoCanViewCategories1.ID = "rdoCanViewCategories1";
				rdoCanViewCategories1.GroupName = "CanViewCategories";
				tdCanViewCategories3.Controls.Add(rdoCanViewCategories1);
				tdCanViewCategories3.Align = "center";
				trCanViewCategories.Controls.Add(tdCanViewCategories3);		
				HtmlTableCell tdCanViewCategories4 = new HtmlTableCell();
				rdoCanViewCategories2.ID = "rdoCanViewCategories2";
				rdoCanViewCategories2.GroupName = "CanViewCategories";
				tdCanViewCategories4.Controls.Add(rdoCanViewCategories2);
				tdCanViewCategories4.Align = "center";
				trCanViewCategories.Controls.Add(tdCanViewCategories4);
				trCanViewCategories.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanViewCategories);
				#endregion

				#region CanAddCategories
				HtmlTableRow trCanAddCategories = new HtmlTableRow();
				HtmlTableCell tdCanAddCategories1 = new HtmlTableCell();
				tdCanAddCategories1.InnerHtml = "<nobr>"+Translate("Can Add Categories")+":</nobr>";
				trCanAddCategories.Controls.Add(tdCanAddCategories1);
				HtmlTableCell tdCanAddCategories2 = new HtmlTableCell();
				rdoCanAddCategories0.ID = "rdoCanAddCategories0";
				rdoCanAddCategories0.GroupName = "CanAddCategories";
				tdCanAddCategories2.Controls.Add(rdoCanAddCategories0);
				tdCanAddCategories2.Align = "center";
				trCanAddCategories.Controls.Add(tdCanAddCategories2);
				HtmlTableCell tdCanAddCategories3 = new HtmlTableCell();
				rdoCanAddCategories1.ID = "rdoCanAddCategories1";
				rdoCanAddCategories1.GroupName = "CanAddCategories";
				tdCanAddCategories3.Controls.Add(rdoCanAddCategories1);
				tdCanAddCategories3.Align = "center";
				trCanAddCategories.Controls.Add(tdCanAddCategories3);
				HtmlTableCell tdCanAddCategories4 = new HtmlTableCell();
				rdoCanAddCategories2.ID = "rdoCanAddCategories2";
				rdoCanAddCategories2.GroupName = "CanAddCategories";
				tdCanAddCategories4.Controls.Add(rdoCanAddCategories2);
				tdCanAddCategories4.Align = "center";
				trCanAddCategories.Controls.Add(tdCanAddCategories4);
				trCanAddCategories.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanAddCategories);
				#endregion

				#region CanEditCategories
				HtmlTableRow trCanEditCategories = new HtmlTableRow();
				HtmlTableCell tdCanEditCategories1 = new HtmlTableCell();
				tdCanEditCategories1.InnerHtml = "<nobr>"+Translate("CanEditCategories")+":</nobr>";
				trCanEditCategories.Controls.Add(tdCanEditCategories1);
				HtmlTableCell tdCanEditCategories2 = new HtmlTableCell();
				rdoCanEditCategories0.ID = "rdoCanEditCategories0";
				rdoCanEditCategories0.GroupName = "CanEditCategories";
				tdCanEditCategories2.Controls.Add(rdoCanEditCategories0);
				tdCanEditCategories2.Align = "center";
				trCanEditCategories.Controls.Add(tdCanEditCategories2);
				HtmlTableCell tdCanEditCategories3 = new HtmlTableCell();
				rdoCanEditCategories1.ID = "rdoCanEditCategories1";
				rdoCanEditCategories1.GroupName = "CanEditCategories";
				tdCanEditCategories3.Controls.Add(rdoCanEditCategories1);
				tdCanEditCategories3.Align = "center";
				trCanEditCategories.Controls.Add(tdCanEditCategories3);
				HtmlTableCell tdCanEditCategories4 = new HtmlTableCell();
				rdoCanEditCategories2.ID = "rdoCanEditCategories2";
				rdoCanEditCategories2.GroupName = "CanEditCategories";
				tdCanEditCategories4.Controls.Add(rdoCanEditCategories2);
				tdCanEditCategories4.Align = "center";
				trCanEditCategories.Controls.Add(tdCanEditCategories4);
				trCanEditCategories.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanEditCategories);
				#endregion

				#region CanDeleteCategories
				HtmlTableRow trCanDeleteCategories = new HtmlTableRow();
				HtmlTableCell tdCanDeleteCategories1 = new HtmlTableCell();
				tdCanDeleteCategories1.InnerHtml = "<nobr>"+Translate("CanDeleteCategories")+":</nobr>";
				trCanDeleteCategories.Controls.Add(tdCanDeleteCategories1);
				HtmlTableCell tdCanDeleteCategories2 = new HtmlTableCell();
				rdoCanDeleteCategories0.ID = "rdoCanDeleteCategories0";
				rdoCanDeleteCategories0.GroupName = "CanDeleteCategories";
				tdCanDeleteCategories2.Controls.Add(rdoCanDeleteCategories0);
				tdCanDeleteCategories2.Align = "center";
				trCanDeleteCategories.Controls.Add(tdCanDeleteCategories2);
				HtmlTableCell tdCanDeleteCategories3 = new HtmlTableCell();
				rdoCanDeleteCategories1.ID = "rdoCanDeleteCategories1";
				rdoCanDeleteCategories1.GroupName = "CanDeleteCategories";
				tdCanDeleteCategories3.Controls.Add(rdoCanDeleteCategories1);
				tdCanDeleteCategories3.Align = "center";
				trCanDeleteCategories.Controls.Add(tdCanDeleteCategories3);
				HtmlTableCell tdCanDeleteCategories4 = new HtmlTableCell();
				rdoCanDeleteCategories2.ID = "rdoCanDeleteCategories2";
				rdoCanDeleteCategories2.GroupName = "CanDeleteCategories";
				tdCanDeleteCategories4.Controls.Add(rdoCanDeleteCategories2);
				tdCanDeleteCategories4.Align = "center";
				trCanDeleteCategories.Controls.Add(tdCanDeleteCategories4);
				trCanDeleteCategories.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanDeleteCategories);
				#endregion

				#region CanManageCategoriesSecurity
				HtmlTableRow trCanManageCategoriesSecurity = new HtmlTableRow();
				HtmlTableCell tdCanManageCategoriesSecurity1 = new HtmlTableCell();
				tdCanManageCategoriesSecurity1.InnerHtml = "<nobr>"+Translate("CanManageCategoriesSecurity")+":</nobr>";
				trCanManageCategoriesSecurity.Controls.Add(tdCanManageCategoriesSecurity1);
				HtmlTableCell tdCanManageCategoriesSecurity2 = new HtmlTableCell();
				rdoCanManageCategoriesSecurity0.ID = "rdoCanManageCategoriesSecurity0";
				rdoCanManageCategoriesSecurity0.GroupName = "CanManageCategoriesSecurity";
				tdCanManageCategoriesSecurity2.Controls.Add(rdoCanManageCategoriesSecurity0);
				tdCanManageCategoriesSecurity2.Align = "center";
				trCanManageCategoriesSecurity.Controls.Add(tdCanManageCategoriesSecurity2);
				HtmlTableCell tdCanManageCategoriesSecurity3 = new HtmlTableCell();
				rdoCanManageCategoriesSecurity1.ID = "rdoCanManageCategoriesSecurity1";
				rdoCanManageCategoriesSecurity1.GroupName = "CanManageCategoriesSecurity";
				tdCanManageCategoriesSecurity3.Controls.Add(rdoCanManageCategoriesSecurity1);
				tdCanManageCategoriesSecurity3.Align = "center";
				trCanManageCategoriesSecurity.Controls.Add(tdCanManageCategoriesSecurity3);
				HtmlTableCell tdCanManageCategoriesSecurity4 = new HtmlTableCell();
				rdoCanManageCategoriesSecurity2.ID = "rdoCanManageCategoriesSecurity2";
				rdoCanManageCategoriesSecurity2.GroupName = "CanManageCategoriesSecurity";
				tdCanManageCategoriesSecurity4.Controls.Add(rdoCanManageCategoriesSecurity2);
				tdCanManageCategoriesSecurity4.Align = "center";
				trCanManageCategoriesSecurity.Controls.Add(tdCanManageCategoriesSecurity4);
				trCanManageCategoriesSecurity.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanManageCategoriesSecurity);
				#endregion
			}
			if(Thread==null && Post==null)
			{
				HtmlTableRow trForums = new HtmlTableRow();
				HtmlTableCell tdForums = new HtmlTableCell();
				tdForums.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Forums Permissions")+":</span>";
				tdForums.Attributes.Add("class", "Forum_Title2");
				tdForums.Attributes.Add("colspan", "4");
				trForums.Controls.Add(tdForums);				
				table2.Controls.Add(trForums);

				#region CanViewForums
				HtmlTableRow trCanViewForums = new HtmlTableRow();
				HtmlTableCell tdCanViewForums1 = new HtmlTableCell();
				tdCanViewForums1.InnerHtml = "<nobr>"+Translate("Can View Forums")+":</nobr>";
				trCanViewForums.Controls.Add(tdCanViewForums1);
				HtmlTableCell tdCanViewForums2 = new HtmlTableCell();
				rdoCanViewForums0.ID = "rdoCanViewForums0";
				rdoCanViewForums0.GroupName = "CanViewForums";
				tdCanViewForums2.Controls.Add(rdoCanViewForums0);
				tdCanViewForums2.Align = "center";
				trCanViewForums.Controls.Add(tdCanViewForums2);
				HtmlTableCell tdCanViewForums3 = new HtmlTableCell();
				rdoCanViewForums1.ID = "rdoCanViewForums1";
				rdoCanViewForums1.GroupName = "CanViewForums";
				tdCanViewForums3.Controls.Add(rdoCanViewForums1);
				tdCanViewForums3.Align = "center";
				trCanViewForums.Controls.Add(tdCanViewForums3);
				HtmlTableCell tdCanViewForums4 = new HtmlTableCell();
				rdoCanViewForums2.ID = "rdoCanViewForums2";
				rdoCanViewForums2.GroupName = "CanViewForums";
				tdCanViewForums4.Controls.Add(rdoCanViewForums2);
				tdCanViewForums4.Align = "center";
				trCanViewForums.Controls.Add(tdCanViewForums4);
				trCanViewForums.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanViewForums);
				#endregion

				#region CanAddForums
				HtmlTableRow trCanAddForums = new HtmlTableRow();
				HtmlTableCell tdCanAddForums1 = new HtmlTableCell();
				tdCanAddForums1.InnerHtml = "<nobr>"+Translate("CanAddForums")+":</nobr>";
				trCanAddForums.Controls.Add(tdCanAddForums1);
				HtmlTableCell tdCanAddForums2 = new HtmlTableCell();
				rdoCanAddForums0.ID = "rdoCanAddForums0";
				rdoCanAddForums0.GroupName = "CanAddForums";
				tdCanAddForums2.Controls.Add(rdoCanAddForums0);
				tdCanAddForums2.Align = "center";
				trCanAddForums.Controls.Add(tdCanAddForums2);
				HtmlTableCell tdCanAddForums3 = new HtmlTableCell();
				rdoCanAddForums1.ID = "rdoCanAddForums1";
				rdoCanAddForums1.GroupName = "CanAddForums";
				tdCanAddForums3.Controls.Add(rdoCanAddForums1);
				tdCanAddForums3.Align = "center";
				trCanAddForums.Controls.Add(tdCanAddForums3);
				HtmlTableCell tdCanAddForums4 = new HtmlTableCell();
				rdoCanAddForums2.ID = "rdoCanAddForums2";
				rdoCanAddForums2.GroupName = "CanAddForums";
				tdCanAddForums4.Controls.Add(rdoCanAddForums2);
				tdCanAddForums4.Align = "center";
				trCanAddForums.Controls.Add(tdCanAddForums4);
				trCanAddForums.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanAddForums);
				#endregion
			
				#region CanEditForums
				HtmlTableRow trCanEditForums = new HtmlTableRow();
				HtmlTableCell tdCanEditForums1 = new HtmlTableCell();
				tdCanEditForums1.InnerHtml = "<nobr>"+Translate("CanEditForums")+":</nobr>";
				trCanEditForums.Controls.Add(tdCanEditForums1);
				HtmlTableCell tdCanEditForums2 = new HtmlTableCell();
				rdoCanEditForums0.ID = "rdoCanEditForums0";
				rdoCanEditForums0.GroupName = "CanEditForums";
				tdCanEditForums2.Controls.Add(rdoCanEditForums0);
				tdCanEditForums2.Align = "center";
				trCanEditForums.Controls.Add(tdCanEditForums2);
				HtmlTableCell tdCanEditForums3 = new HtmlTableCell();
				rdoCanEditForums1.ID = "rdoCanEditForums1";
				rdoCanEditForums1.GroupName = "CanEditForums";
				tdCanEditForums3.Controls.Add(rdoCanEditForums1);
				tdCanEditForums3.Align = "center";
				trCanEditForums.Controls.Add(tdCanEditForums3);
				HtmlTableCell tdCanEditForums4 = new HtmlTableCell();
				rdoCanEditForums2.ID = "rdoCanEditForums2";
				rdoCanEditForums2.GroupName = "CanEditForums";
				tdCanEditForums4.Controls.Add(rdoCanEditForums2);
				tdCanEditForums4.Align = "center";
				trCanEditForums.Controls.Add(tdCanEditForums4);
				trCanEditForums.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanEditForums);
				#endregion

				#region CanDeleteForums
				HtmlTableRow trCanDeleteForums = new HtmlTableRow();
				HtmlTableCell tdCanDeleteForums1 = new HtmlTableCell();
				tdCanDeleteForums1.InnerHtml = "<nobr>"+Translate("CanDeleteForums")+":</nobr>";
				trCanDeleteForums.Controls.Add(tdCanDeleteForums1);
				HtmlTableCell tdCanDeleteForums2 = new HtmlTableCell();
				rdoCanDeleteForums0.ID = "rdoCanDeleteForums0";
				rdoCanDeleteForums0.GroupName = "CanDeleteForums";
				tdCanDeleteForums2.Controls.Add(rdoCanDeleteForums0);
				tdCanDeleteForums2.Align = "center";
				trCanDeleteForums.Controls.Add(tdCanDeleteForums2);
				HtmlTableCell tdCanDeleteForums3 = new HtmlTableCell();
				rdoCanDeleteForums1.ID = "rdoCanDeleteForums1";
				rdoCanDeleteForums1.GroupName = "CanDeleteForums";
				tdCanDeleteForums3.Controls.Add(rdoCanDeleteForums1);
				tdCanDeleteForums3.Align = "center";
				trCanDeleteForums.Controls.Add(tdCanDeleteForums3);
				HtmlTableCell tdCanDeleteForums4 = new HtmlTableCell();
				rdoCanDeleteForums2.ID = "rdoCanDeleteForums2";
				rdoCanDeleteForums2.GroupName = "CanDeleteForums";
				tdCanDeleteForums4.Controls.Add(rdoCanDeleteForums2);
				tdCanDeleteForums4.Align = "center";
				trCanDeleteForums.Controls.Add(tdCanDeleteForums4);
				trCanDeleteForums.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanDeleteForums);
				#endregion

				#region CanManageForumsSecurity
				HtmlTableRow trCanManageForumsSecurity = new HtmlTableRow();
				HtmlTableCell tdCanManageForumsSecurity1 = new HtmlTableCell();
				tdCanManageForumsSecurity1.InnerHtml = "<nobr>"+Translate("CanManageForumsSecurity")+":</nobr>";
				trCanManageForumsSecurity.Controls.Add(tdCanManageForumsSecurity1);
				HtmlTableCell tdCanManageForumsSecurity2 = new HtmlTableCell();
				rdoCanManageForumsSecurity0.ID = "rdoCanManageForumsSecurity0";
				rdoCanManageForumsSecurity0.GroupName = "CanManageForumsSecurity";
				tdCanManageForumsSecurity2.Controls.Add(rdoCanManageForumsSecurity0);
				tdCanManageForumsSecurity2.Align = "center";
				trCanManageForumsSecurity.Controls.Add(tdCanManageForumsSecurity2);
				HtmlTableCell tdCanManageForumsSecurity3 = new HtmlTableCell();
				rdoCanManageForumsSecurity1.ID = "rdoCanManageForumsSecurity1";
				rdoCanManageForumsSecurity1.GroupName = "CanManageForumsSecurity";
				tdCanManageForumsSecurity3.Controls.Add(rdoCanManageForumsSecurity1);
				tdCanManageForumsSecurity3.Align = "center";
				trCanManageForumsSecurity.Controls.Add(tdCanManageForumsSecurity3);
				HtmlTableCell tdCanManageForumsSecurity4 = new HtmlTableCell();
				rdoCanManageForumsSecurity2.ID = "rdoCanManageForumsSecurity2";
				rdoCanManageForumsSecurity2.GroupName = "CanManageForumsSecurity";
				tdCanManageForumsSecurity4.Controls.Add(rdoCanManageForumsSecurity2);
				tdCanManageForumsSecurity4.Align = "center";
				trCanManageForumsSecurity.Controls.Add(tdCanManageForumsSecurity4);
				trCanManageForumsSecurity.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanManageForumsSecurity);
				#endregion
			}
			if(Post==null)
			{
				HtmlTableRow trThreads = new HtmlTableRow();
				HtmlTableCell tdThreads = new HtmlTableCell();
				tdThreads.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Threads Permissions")+":</span>";
				tdThreads.Attributes.Add("class", "Forum_Title2");
				tdThreads.Attributes.Add("colspan", "4");
				trThreads.Controls.Add(tdThreads);				
				table2.Controls.Add(trThreads);

				#region CanViewThreads
				HtmlTableRow trCanViewThreads = new HtmlTableRow();
				HtmlTableCell tdCanViewThreads1 = new HtmlTableCell();
				tdCanViewThreads1.InnerHtml = "<nobr>"+Translate("Can View Threads")+":</nobr>";
				trCanViewThreads.Controls.Add(tdCanViewThreads1);
				HtmlTableCell tdCanViewThreads2 = new HtmlTableCell();
				rdoCanViewThreads0.ID = "rdoCanViewThreads0";
				rdoCanViewThreads0.GroupName = "CanViewThreads";
				tdCanViewThreads2.Controls.Add(rdoCanViewThreads0);
				tdCanViewThreads2.Align = "center";
				trCanViewThreads.Controls.Add(tdCanViewThreads2);
				HtmlTableCell tdCanViewThreads3 = new HtmlTableCell();
				rdoCanViewThreads1.ID = "rdoCanViewThreads1";
				rdoCanViewThreads1.GroupName = "CanViewThreads";
				tdCanViewThreads3.Controls.Add(rdoCanViewThreads1);
				tdCanViewThreads3.Align = "center";
				trCanViewThreads.Controls.Add(tdCanViewThreads3);
				HtmlTableCell tdCanViewThreads4 = new HtmlTableCell();
				rdoCanViewThreads2.ID = "rdoCanViewThreads2";
				rdoCanViewThreads2.GroupName = "CanViewThreads";
				tdCanViewThreads4.Controls.Add(rdoCanViewThreads2);
				tdCanViewThreads4.Align = "center";
				trCanViewThreads.Controls.Add(tdCanViewThreads4);
				trCanViewThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanViewThreads);
				#endregion

				#region CanAddThreads
				HtmlTableRow trCanAddThreads = new HtmlTableRow();
				HtmlTableCell tdCanAddThreads1 = new HtmlTableCell();
				tdCanAddThreads1.InnerHtml = "<nobr>"+Translate("CanAddThreads")+":</nobr>";
				trCanAddThreads.Controls.Add(tdCanAddThreads1);
				HtmlTableCell tdCanAddThreads2 = new HtmlTableCell();
				rdoCanAddThreads0.ID = "rdoCanAddThreads0";
				rdoCanAddThreads0.GroupName = "CanAddThreads";
				tdCanAddThreads2.Controls.Add(rdoCanAddThreads0);
				tdCanAddThreads2.Align = "center";
				trCanAddThreads.Controls.Add(tdCanAddThreads2);
				HtmlTableCell tdCanAddThreads3 = new HtmlTableCell();
				rdoCanAddThreads1.ID = "rdoCanAddThreads1";
				rdoCanAddThreads1.GroupName = "CanAddThreads";
				tdCanAddThreads3.Controls.Add(rdoCanAddThreads1);
				tdCanAddThreads3.Align = "center";
				trCanAddThreads.Controls.Add(tdCanAddThreads3);
				HtmlTableCell tdCanAddThreads4 = new HtmlTableCell();
				rdoCanAddThreads2.ID = "rdoCanAddThreads2";
				rdoCanAddThreads2.GroupName = "CanAddThreads";
				tdCanAddThreads4.Controls.Add(rdoCanAddThreads2);
				tdCanAddThreads4.Align = "center";
				trCanAddThreads.Controls.Add(tdCanAddThreads4);
				trCanAddThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanAddThreads);
				#endregion
			
				#region CanEditThreads
				HtmlTableRow trCanEditThreads = new HtmlTableRow();
				HtmlTableCell tdCanEditThreads1 = new HtmlTableCell();
				tdCanEditThreads1.InnerHtml = "<nobr>"+Translate("CanEditThreads")+":</nobr>";
				trCanEditThreads.Controls.Add(tdCanEditThreads1);
				HtmlTableCell tdCanEditThreads2 = new HtmlTableCell();
				rdoCanEditThreads0.ID = "rdoCanEditThreads0";
				rdoCanEditThreads0.GroupName = "CanEditThreads";
				tdCanEditThreads2.Controls.Add(rdoCanEditThreads0);
				tdCanEditThreads2.Align = "center";
				trCanEditThreads.Controls.Add(tdCanEditThreads2);
				HtmlTableCell tdCanEditThreads3 = new HtmlTableCell();
				rdoCanEditThreads1.ID = "rdoCanEditThreads1";
				rdoCanEditThreads1.GroupName = "CanEditThreads";
				tdCanEditThreads3.Controls.Add(rdoCanEditThreads1);
				tdCanEditThreads3.Align = "center";
				trCanEditThreads.Controls.Add(tdCanEditThreads3);
				HtmlTableCell tdCanEditThreads4 = new HtmlTableCell();
				rdoCanEditThreads2.ID = "rdoCanEditThreads2";
				rdoCanEditThreads2.GroupName = "CanEditThreads";
				tdCanEditThreads4.Controls.Add(rdoCanEditThreads2);
				tdCanEditThreads4.Align = "center";
				trCanEditThreads.Controls.Add(tdCanEditThreads4);
				trCanEditThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanEditThreads);
				#endregion

				#region CanEditHisThreads
				HtmlTableRow trCanEditHisThreads = new HtmlTableRow();
				HtmlTableCell tdCanEditHisThreads1 = new HtmlTableCell();
				tdCanEditHisThreads1.InnerHtml = "<nobr>"+Translate("CanEditHisThreads")+":</nobr>";
				trCanEditHisThreads.Controls.Add(tdCanEditHisThreads1);
				HtmlTableCell tdCanEditHisThreads2 = new HtmlTableCell();
				rdoCanEditHisThreads0.ID = "rdoCanEditHisThreads0";
				rdoCanEditHisThreads0.GroupName = "CanEditHisThreads";
				tdCanEditHisThreads2.Controls.Add(rdoCanEditHisThreads0);
				tdCanEditHisThreads2.Align = "center";
				trCanEditHisThreads.Controls.Add(tdCanEditHisThreads2);
				HtmlTableCell tdCanEditHisThreads3 = new HtmlTableCell();
				rdoCanEditHisThreads1.ID = "rdoCanEditHisThreads1";
				rdoCanEditHisThreads1.GroupName = "CanEditHisThreads";
				tdCanEditHisThreads3.Controls.Add(rdoCanEditHisThreads1);
				tdCanEditHisThreads3.Align = "center";
				trCanEditHisThreads.Controls.Add(tdCanEditHisThreads3);
				HtmlTableCell tdCanEditHisThreads4 = new HtmlTableCell();
				rdoCanEditHisThreads2.ID = "rdoCanEditHisThreads2";
				rdoCanEditHisThreads2.GroupName = "CanEditHisThreads";
				tdCanEditHisThreads4.Controls.Add(rdoCanEditHisThreads2);
				tdCanEditHisThreads4.Align = "center";
				trCanEditHisThreads.Controls.Add(tdCanEditHisThreads4);
				trCanEditHisThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanEditHisThreads);
				#endregion

				#region CanDeleteThreads
				HtmlTableRow trCanDeleteThreads = new HtmlTableRow();
				HtmlTableCell tdCanDeleteThreads1 = new HtmlTableCell();
				tdCanDeleteThreads1.InnerHtml = "<nobr>"+Translate("CanDeleteThreads")+":</nobr>";
				trCanDeleteThreads.Controls.Add(tdCanDeleteThreads1);
				HtmlTableCell tdCanDeleteThreads2 = new HtmlTableCell();
				rdoCanDeleteThreads0.ID = "rdoCanDeleteThreads0";
				rdoCanDeleteThreads0.GroupName = "CanDeleteThreads";
				tdCanDeleteThreads2.Controls.Add(rdoCanDeleteThreads0);
				tdCanDeleteThreads2.Align = "center";
				trCanDeleteThreads.Controls.Add(tdCanDeleteThreads2);
				HtmlTableCell tdCanDeleteThreads3 = new HtmlTableCell();
				rdoCanDeleteThreads1.ID = "rdoCanDeleteThreads1";
				rdoCanDeleteThreads1.GroupName = "CanDeleteThreads";
				tdCanDeleteThreads3.Controls.Add(rdoCanDeleteThreads1);
				tdCanDeleteThreads3.Align = "center";
				trCanDeleteThreads.Controls.Add(tdCanDeleteThreads3);
				HtmlTableCell tdCanDeleteThreads4 = new HtmlTableCell();
				rdoCanDeleteThreads2.ID = "rdoCanDeleteThreads2";
				rdoCanDeleteThreads2.GroupName = "CanDeleteThreads";
				tdCanDeleteThreads4.Controls.Add(rdoCanDeleteThreads2);
				tdCanDeleteThreads4.Align = "center";
				trCanDeleteThreads.Controls.Add(tdCanDeleteThreads4);
				trCanDeleteThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanDeleteThreads);
				#endregion

				#region CanDeleteHisThreads
				HtmlTableRow trCanDeleteHisThreads = new HtmlTableRow();
				HtmlTableCell tdCanDeleteHisThreads1 = new HtmlTableCell();
				tdCanDeleteHisThreads1.InnerHtml = "<nobr>"+Translate("CanDeleteHisThreads")+":</nobr>";
				trCanDeleteHisThreads.Controls.Add(tdCanDeleteHisThreads1);
				HtmlTableCell tdCanDeleteHisThreads2 = new HtmlTableCell();
				rdoCanDeleteHisThreads0.ID = "rdoCanDeleteHisThreads0";
				rdoCanDeleteHisThreads0.GroupName = "CanDeleteHisThreads";
				tdCanDeleteHisThreads2.Controls.Add(rdoCanDeleteHisThreads0);
				tdCanDeleteHisThreads2.Align = "center";
				trCanDeleteHisThreads.Controls.Add(tdCanDeleteHisThreads2);
				HtmlTableCell tdCanDeleteHisThreads3 = new HtmlTableCell();
				rdoCanDeleteHisThreads1.ID = "rdoCanDeleteHisThreads1";
				rdoCanDeleteHisThreads1.GroupName = "CanDeleteHisThreads";
				tdCanDeleteHisThreads3.Controls.Add(rdoCanDeleteHisThreads1);
				tdCanDeleteHisThreads3.Align = "center";
				trCanDeleteHisThreads.Controls.Add(tdCanDeleteHisThreads3);
				HtmlTableCell tdCanDeleteHisThreads4 = new HtmlTableCell();
				rdoCanDeleteHisThreads2.ID = "rdoCanDeleteHisThreads2";
				rdoCanDeleteHisThreads2.GroupName = "CanDeleteHisThreads";
				tdCanDeleteHisThreads4.Controls.Add(rdoCanDeleteHisThreads2);
				tdCanDeleteHisThreads4.Align = "center";
				trCanDeleteHisThreads.Controls.Add(tdCanDeleteHisThreads4);
				trCanDeleteHisThreads.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanDeleteHisThreads);
				#endregion

				#region CanManageThreadsSecurity
				HtmlTableRow trCanManageThreadsSecurity = new HtmlTableRow();
				HtmlTableCell tdCanManageThreadsSecurity1 = new HtmlTableCell();
				tdCanManageThreadsSecurity1.InnerHtml = "<nobr>"+Translate("CanManageThreadsSecurity")+":</nobr>";
				trCanManageThreadsSecurity.Controls.Add(tdCanManageThreadsSecurity1);
				HtmlTableCell tdCanManageThreadsSecurity2 = new HtmlTableCell();
				rdoCanManageThreadsSecurity0.ID = "rdoCanManageThreadsSecurity0";
				rdoCanManageThreadsSecurity0.GroupName = "CanManageThreadsSecurity";
				tdCanManageThreadsSecurity2.Controls.Add(rdoCanManageThreadsSecurity0);
				tdCanManageThreadsSecurity2.Align = "center";
				trCanManageThreadsSecurity.Controls.Add(tdCanManageThreadsSecurity2);
				HtmlTableCell tdCanManageThreadsSecurity3 = new HtmlTableCell();
				rdoCanManageThreadsSecurity1.ID = "rdoCanManageThreadsSecurity1";
				rdoCanManageThreadsSecurity1.GroupName = "CanManageThreadsSecurity";
				tdCanManageThreadsSecurity3.Controls.Add(rdoCanManageThreadsSecurity1);
				tdCanManageThreadsSecurity3.Align = "center";
				trCanManageThreadsSecurity.Controls.Add(tdCanManageThreadsSecurity3);
				HtmlTableCell tdCanManageThreadsSecurity4 = new HtmlTableCell();
				rdoCanManageThreadsSecurity2.ID = "rdoCanManageThreadsSecurity2";
				rdoCanManageThreadsSecurity2.GroupName = "CanManageThreadsSecurity";
				tdCanManageThreadsSecurity4.Controls.Add(rdoCanManageThreadsSecurity2);
				tdCanManageThreadsSecurity4.Align = "center";
				trCanManageThreadsSecurity.Controls.Add(tdCanManageThreadsSecurity4);
				trCanManageThreadsSecurity.Attributes.Add("class", "Forum_Title4");
				table2.Controls.Add(trCanManageThreadsSecurity);
				#endregion
			}

			HtmlTableRow trPosts = new HtmlTableRow();
			HtmlTableCell tdPosts = new HtmlTableCell();
			tdPosts.InnerHtml = "<span class='Forum_BoldText'>"+Translate("Posts Permissions")+":</span>";
			tdPosts.Attributes.Add("class", "Forum_Title2");
			tdPosts.Attributes.Add("colspan", "4");
			trPosts.Controls.Add(tdPosts);				
			table2.Controls.Add(trPosts);

			#region CanViewPosts
			HtmlTableRow trCanViewPosts = new HtmlTableRow();
			HtmlTableCell tdCanViewPosts1 = new HtmlTableCell();
			tdCanViewPosts1.InnerHtml = "<nobr>"+Translate("Can View Posts")+":</nobr>";
			trCanViewPosts.Controls.Add(tdCanViewPosts1);
			HtmlTableCell tdCanViewPosts2 = new HtmlTableCell();
			rdoCanViewPosts0.ID = "rdoCanViewPosts0";
			rdoCanViewPosts0.GroupName = "CanViewPosts";
			tdCanViewPosts2.Controls.Add(rdoCanViewPosts0);
			tdCanViewPosts2.Align = "center";
			trCanViewPosts.Controls.Add(tdCanViewPosts2);
			HtmlTableCell tdCanViewPosts3 = new HtmlTableCell();
			rdoCanViewPosts1.ID = "rdoCanViewPosts1";
			rdoCanViewPosts1.GroupName = "CanViewPosts";
			tdCanViewPosts3.Controls.Add(rdoCanViewPosts1);
			tdCanViewPosts3.Align = "center";
			trCanViewPosts.Controls.Add(tdCanViewPosts3);
			HtmlTableCell tdCanViewPosts4 = new HtmlTableCell();
			rdoCanViewPosts2.ID = "rdoCanViewPosts2";
			rdoCanViewPosts2.GroupName = "CanViewPosts";
			tdCanViewPosts4.Controls.Add(rdoCanViewPosts2);
			tdCanViewPosts4.Align = "center";
			trCanViewPosts.Controls.Add(tdCanViewPosts4);
			trCanViewPosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanViewPosts);
			#endregion

			#region CanAddPosts
			HtmlTableRow trCanAddPosts = new HtmlTableRow();
			HtmlTableCell tdCanAddPosts1 = new HtmlTableCell();
			tdCanAddPosts1.InnerHtml = "<nobr>"+Translate("CanAddPosts")+":</nobr>";
			trCanAddPosts.Controls.Add(tdCanAddPosts1);
			HtmlTableCell tdCanAddPosts2 = new HtmlTableCell();
			rdoCanAddPosts0.ID = "rdoCanAddPosts0";
			rdoCanAddPosts0.GroupName = "CanAddPosts";
			tdCanAddPosts2.Controls.Add(rdoCanAddPosts0);
			tdCanAddPosts2.Align = "center";
			trCanAddPosts.Controls.Add(tdCanAddPosts2);
			HtmlTableCell tdCanAddPosts3 = new HtmlTableCell();
			rdoCanAddPosts1.ID = "rdoCanAddPosts1";
			rdoCanAddPosts1.GroupName = "CanAddPosts";
			tdCanAddPosts3.Controls.Add(rdoCanAddPosts1);
			tdCanAddPosts3.Align = "center";
			trCanAddPosts.Controls.Add(tdCanAddPosts3);
			HtmlTableCell tdCanAddPosts4 = new HtmlTableCell();
			rdoCanAddPosts2.ID = "rdoCanAddPosts2";
			rdoCanAddPosts2.GroupName = "CanAddPosts";
			tdCanAddPosts4.Controls.Add(rdoCanAddPosts2);
			tdCanAddPosts4.Align = "center";
			trCanAddPosts.Controls.Add(tdCanAddPosts4);
			trCanAddPosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanAddPosts);
			#endregion
		
			#region CanEditPosts
			HtmlTableRow trCanEditPosts = new HtmlTableRow();
			HtmlTableCell tdCanEditPosts1 = new HtmlTableCell();
			tdCanEditPosts1.InnerHtml = "<nobr>"+Translate("CanEditPosts")+":</nobr>";
			trCanEditPosts.Controls.Add(tdCanEditPosts1);
			HtmlTableCell tdCanEditPosts2 = new HtmlTableCell();
			rdoCanEditPosts0.ID = "rdoCanEditPosts0";
			rdoCanEditPosts0.GroupName = "CanEditPosts";
			tdCanEditPosts2.Controls.Add(rdoCanEditPosts0);
			tdCanEditPosts2.Align = "center";
			trCanEditPosts.Controls.Add(tdCanEditPosts2);
			HtmlTableCell tdCanEditPosts3 = new HtmlTableCell();
			rdoCanEditPosts1.ID = "rdoCanEditPosts1";
			rdoCanEditPosts1.GroupName = "CanEditPosts";
			tdCanEditPosts3.Controls.Add(rdoCanEditPosts1);
			tdCanEditPosts3.Align = "center";
			trCanEditPosts.Controls.Add(tdCanEditPosts3);
			HtmlTableCell tdCanEditPosts4 = new HtmlTableCell();
			rdoCanEditPosts2.ID = "rdoCanEditPosts2";
			rdoCanEditPosts2.GroupName = "CanEditPosts";
			tdCanEditPosts4.Controls.Add(rdoCanEditPosts2);
			tdCanEditPosts4.Align = "center";
			trCanEditPosts.Controls.Add(tdCanEditPosts4);
			trCanEditPosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanEditPosts);
			#endregion			
		
			#region CanEditHisPosts
			HtmlTableRow trCanEditHisPosts = new HtmlTableRow();
			HtmlTableCell tdCanEditHisPosts1 = new HtmlTableCell();
			tdCanEditHisPosts1.InnerHtml = "<nobr>"+Translate("CanEditHisPosts")+":</nobr>";
			trCanEditHisPosts.Controls.Add(tdCanEditHisPosts1);
			HtmlTableCell tdCanEditHisPosts2 = new HtmlTableCell();
			rdoCanEditHisPosts0.ID = "rdoCanEditHisPosts0";
			rdoCanEditHisPosts0.GroupName = "CanEditHisPosts";
			tdCanEditHisPosts2.Controls.Add(rdoCanEditHisPosts0);
			tdCanEditHisPosts2.Align = "center";
			trCanEditHisPosts.Controls.Add(tdCanEditHisPosts2);
			HtmlTableCell tdCanEditHisPosts3 = new HtmlTableCell();
			rdoCanEditHisPosts1.ID = "rdoCanEditHisPosts1";
			rdoCanEditHisPosts1.GroupName = "CanEditHisPosts";
			tdCanEditHisPosts3.Controls.Add(rdoCanEditHisPosts1);
			tdCanEditHisPosts3.Align = "center";
			trCanEditHisPosts.Controls.Add(tdCanEditHisPosts3);
			HtmlTableCell tdCanEditHisPosts4 = new HtmlTableCell();
			rdoCanEditHisPosts2.ID = "rdoCanEditHisPosts2";
			rdoCanEditHisPosts2.GroupName = "CanEditHisPosts";
			tdCanEditHisPosts4.Controls.Add(rdoCanEditHisPosts2);
			tdCanEditHisPosts4.Align = "center";
			trCanEditHisPosts.Controls.Add(tdCanEditHisPosts4);
			trCanEditHisPosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanEditHisPosts);
			#endregion			

			#region CanDeletePosts
			HtmlTableRow trCanDeletePosts = new HtmlTableRow();
			HtmlTableCell tdCanDeletePosts1 = new HtmlTableCell();
			tdCanDeletePosts1.InnerHtml = "<nobr>"+Translate("CanDeletePosts")+":</nobr>";
			trCanDeletePosts.Controls.Add(tdCanDeletePosts1);
			HtmlTableCell tdCanDeletePosts2 = new HtmlTableCell();
			rdoCanDeletePosts0.ID = "rdoCanDeletePosts0";
			rdoCanDeletePosts0.GroupName = "CanDeletePosts";
			tdCanDeletePosts2.Controls.Add(rdoCanDeletePosts0);
			tdCanDeletePosts2.Align = "center";
			trCanDeletePosts.Controls.Add(tdCanDeletePosts2);
			HtmlTableCell tdCanDeletePosts3 = new HtmlTableCell();
			rdoCanDeletePosts1.ID = "rdoCanDeletePosts1";
			rdoCanDeletePosts1.GroupName = "CanDeletePosts";
			tdCanDeletePosts3.Controls.Add(rdoCanDeletePosts1);
			tdCanDeletePosts3.Align = "center";
			trCanDeletePosts.Controls.Add(tdCanDeletePosts3);
			HtmlTableCell tdCanDeletePosts4 = new HtmlTableCell();
			rdoCanDeletePosts2.ID = "rdoCanDeletePosts2";
			rdoCanDeletePosts2.GroupName = "CanDeletePosts";
			tdCanDeletePosts4.Controls.Add(rdoCanDeletePosts2);
			tdCanDeletePosts4.Align = "center";
			trCanDeletePosts.Controls.Add(tdCanDeletePosts4);
			trCanDeletePosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanDeletePosts);
			#endregion

			#region CanDeleteHisPosts
			HtmlTableRow trCanDeleteHisPosts = new HtmlTableRow();
			HtmlTableCell tdCanDeleteHisPosts1 = new HtmlTableCell();
			tdCanDeleteHisPosts1.InnerHtml = "<nobr>"+Translate("CanDeleteHisPosts")+":</nobr>";
			trCanDeleteHisPosts.Controls.Add(tdCanDeleteHisPosts1);
			HtmlTableCell tdCanDeleteHisPosts2 = new HtmlTableCell();
			rdoCanDeleteHisPosts0.ID = "rdoCanDeleteHisPosts0";
			rdoCanDeleteHisPosts0.GroupName = "CanDeleteHisPosts";
			tdCanDeleteHisPosts2.Controls.Add(rdoCanDeleteHisPosts0);
			tdCanDeleteHisPosts2.Align = "center";
			trCanDeleteHisPosts.Controls.Add(tdCanDeleteHisPosts2);
			HtmlTableCell tdCanDeleteHisPosts3 = new HtmlTableCell();
			rdoCanDeleteHisPosts1.ID = "rdoCanDeleteHisPosts1";
			rdoCanDeleteHisPosts1.GroupName = "CanDeleteHisPosts";
			tdCanDeleteHisPosts3.Controls.Add(rdoCanDeleteHisPosts1);
			tdCanDeleteHisPosts3.Align = "center";
			trCanDeleteHisPosts.Controls.Add(tdCanDeleteHisPosts3);
			HtmlTableCell tdCanDeleteHisPosts4 = new HtmlTableCell();
			rdoCanDeleteHisPosts2.ID = "rdoCanDeleteHisPosts2";
			rdoCanDeleteHisPosts2.GroupName = "CanDeleteHisPosts";
			tdCanDeleteHisPosts4.Controls.Add(rdoCanDeleteHisPosts2);
			tdCanDeleteHisPosts4.Align = "center";
			trCanDeleteHisPosts.Controls.Add(tdCanDeleteHisPosts4);
			trCanDeleteHisPosts.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanDeleteHisPosts);
			#endregion

			#region CanManagePostsSecurity
			HtmlTableRow trCanManagePostsSecurity = new HtmlTableRow();
			HtmlTableCell tdCanManagePostsSecurity1 = new HtmlTableCell();
			tdCanManagePostsSecurity1.InnerHtml = "<nobr>"+Translate("CanManagePostsSecurity")+":</nobr>";
			trCanManagePostsSecurity.Controls.Add(tdCanManagePostsSecurity1);
			HtmlTableCell tdCanManagePostsSecurity2 = new HtmlTableCell();
			rdoCanManagePostsSecurity0.ID = "rdoCanManagePostsSecurity0";
			rdoCanManagePostsSecurity0.GroupName = "CanManagePostsSecurity";
			tdCanManagePostsSecurity2.Controls.Add(rdoCanManagePostsSecurity0);
			tdCanManagePostsSecurity2.Align = "center";
			trCanManagePostsSecurity.Controls.Add(tdCanManagePostsSecurity2);
			HtmlTableCell tdCanManagePostsSecurity3 = new HtmlTableCell();
			rdoCanManagePostsSecurity1.ID = "rdoCanManagePostsSecurity1";
			rdoCanManagePostsSecurity1.GroupName = "CanManagePostsSecurity";
			tdCanManagePostsSecurity3.Controls.Add(rdoCanManagePostsSecurity1);
			tdCanManagePostsSecurity3.Align = "center";
			trCanManagePostsSecurity.Controls.Add(tdCanManagePostsSecurity3);
			HtmlTableCell tdCanManagePostsSecurity4 = new HtmlTableCell();
			rdoCanManagePostsSecurity2.ID = "rdoCanManagePostsSecurity2";
			rdoCanManagePostsSecurity2.GroupName = "CanManagePostsSecurity";
			tdCanManagePostsSecurity4.Controls.Add(rdoCanManagePostsSecurity2);
			tdCanManagePostsSecurity4.Align = "center";
			trCanManagePostsSecurity.Controls.Add(tdCanManagePostsSecurity4);
			trCanManagePostsSecurity.Attributes.Add("class", "Forum_Title4");
			table2.Controls.Add(trCanManagePostsSecurity);
			#endregion
			
			HtmlTableRow tr = new HtmlTableRow();
			HtmlTableCell td = new HtmlTableCell();
			td.ColSpan = 4;
			tr.Controls.Add(td);
			table.Controls.Add(tr);

			


			

			td.Controls.Add(tableOut);
			#endregion
		}

		private MessageBoard.CustomControl customControl = MessageBoard.CustomControl.Get("ManageSecurity");

		private string Translate(string word)
		{
			return MessageBoard.Translation.Get(customControl, word, Language).Equal;
		}
	}
}
